import React, { useEffect, useState } from 'react';
import { getClassGuanLi } from '@/services/index';
import { Table, Tag, Space, Modal, Button } from 'antd';

const columns = [
  {
    title: '班级名',
    dataIndex: 'grade_name',
    key: 'grade_name',
    render: (text: any) => <a>{text}</a>,
  },
  {
    title: '课程名',
    dataIndex: 'subject_text',
    key: 'subject_text',
  },
  {
    title: '教室号',
    dataIndex: 'room_text',
    key: 'room_text',
  },
  {
    title: '操作',
    key: 'tags',
    dataIndex: 'tags',
  },
];

const GraderClass: React.FC = () => {
  //按钮班级管理
  const [isModalVisible, setIsModalVisible] = useState(false);
  const showModal = () => {
    setIsModalVisible(true);
  };
  const handleOk = () => {
    setIsModalVisible(false);
  };
  const handleCancel = () => {
    setIsModalVisible(false);
  };
  //班级管理
  const [getGrade, setgetGrade] = useState<any[]>([]);
  useEffect(() => {
    getClassGuanLi().then((res) => {
      setgetGrade(res.data);
      // debugger;
    });
  }, []);
  return (
    <div>
      <h1>班级管理</h1>
      <>
        <Button type="primary" onClick={showModal}>
          +添加班级
        </Button>
        <Modal
          title="Basic Modal"
          visible={isModalVisible}
          onOk={handleOk}
          onCancel={handleCancel}
        >
          <p>Some contents...</p>
          <p>Some contents...</p>
          <p>Some contents...</p>
        </Modal>
      </>
      <Table columns={columns} dataSource={getGrade} />
    </div>
  );
};
export default GraderClass;
